<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/WEB-INF/templates/default.xhtml">

	<ui:define name="menu">
		<ul>
			<li><h:link value="Home"  outcome="/index" /> </li>
			<li><h:link value="Users"  outcome="/content/user/list" /> </li>
			<li><h:link value="Resources"  outcome="/content/resource/list" /> </li>
			<li><h:link class="akt" value="Tasks"  outcome="/content/task/list" /> </li>
			<li><h:link value="Task types"  outcome="/content/tasktype/list" /> </li>
		</ul>
		<p class="vonal"><br/></p>
	</ui:define>

	<f:metadata>
		<f:viewParam name="id" value="#{taskBean.id}" />
		<f:event type="preRenderView" listener="#{taskBean.load}" />
	</f:metadata>

	<ui:define name="content2">
		<h:form id="taskEditForm">
			<h:link outcome="/content/resource/listbytask"
				value="Resources" includeViewParams="true">
				<f:param name="taskId" value="#{taskBean.task.id}" />
			</h:link>
			
			<h:panelGrid columns="3" cellpadding="0" cellspacing="20">
				<h:outputLabel for="name" value="Name: " />
				<h:inputText id="name" style="background-color:#F5FFFA; width: 150px;"
					value="#{taskBean.task.name}" />
				<h:message for="name" styleClass="error" errorStyle="color:red" />

				<h:outputLabel for="desc" value="Description: " />
				<h:inputTextarea id="desc" style="background-color:#F5FFFA; width:400px;height:50px;resize: none"
					value="#{taskBean.task.description}" />
				<h:message for="desc" styleClass="error" errorStyle="color:red" /> 

				<h:outputLabel for="estimated" value="Estimated: " />
				<h:inputText id="estimated" style="background-color:#F5FFFA; width: 150px;"
					value="#{taskBean.task.estimated}" />
				<h:message for="estimated" styleClass="error" errorStyle="color:red" />

				<h:outputLabel for="remaining" value="Remaining: " />
				<h:inputText id="remaining" style="background-color:#F5FFFA; width: 150px;"
					value="#{taskBean.task.remaining}" />
				<h:message for="remaining" styleClass="error" errorStyle="color:red" />

				<h:outputLabel for="completed" value="Completed: " />
				<h:inputText id="completed" style="background-color:#F5FFFA; width: 150px;"
					value="#{taskBean.task.completed}" />
				<h:message for="completed" styleClass="error" errorStyle="color:red" />

				<h:outputLabel for="tasktypet" value="Type: " />
				<h:selectOneMenu converter="#{taskTypeBean.converter}"
					id="tasktypet" value="#{taskBean.task.taskType}" 
					style="background-color:#F5FFFA; width: 150px;">
					<f:selectItem />
					<f:selectItems value="#{taskTypeListBean.loadAllTaskTypes()}" var="type" 
					    itemValue="#{type}" itemLabel="#{type.name}"/>
				</h:selectOneMenu>
				<h:message for="tasktypet" styleClass="error" />

				<h:outputLabel for="username" value="User name: " />
				<h:selectOneMenu converter="#{userBean.converter}"   
					id="username" value="#{taskBean.task.user}" 
					style="background-color:#F5FFFA; width: 150px;">
					<f:selectItem />
					<f:selectItems value="#{userListBean.loadAllUsers()}" var="user" 
					    itemValue="#{user}" itemLabel="#{user.name}"/>
				</h:selectOneMenu>
				<h:message for="user" styleClass="error" />
				
				
				<h:outputLabel for="resourcename" value="Resource name: " />
				<h:selectOneMenu converter="#{resourceBean.converter}"
					id="resourcename" value="#{taskBean.task.resource}" 
					style="background-color:#F5FFFA; width: 150px;">
					<f:selectItem />
					<f:selectItems value="#{resourceListBean.loadAllResources()}" var="res" 
					    itemValue="#{res}" itemLabel="#{res.name}"/>
				</h:selectOneMenu>
				<h:message for="resourcename" styleClass="error" />

				<h:outputLabel for="fulfill" value="Complete: " />
				<h:selectOneMenu id="fulfill" style="background-color:#F5FFFA; width: 150px;"
					value="#{taskBean.task.fulfill}" >
					<f:selectItem id="item1" itemLabel="No" itemValue="No" />
					<f:selectItem id="item2" itemLabel="Yes" itemValue="Yes" />
				</h:selectOneMenu>
				<h:message for="fulfill" styleClass="error" />

				<h:commandButton value="Save" action="#{taskBean.save()}"
					style="background-color:#F5FFFA; width: 100px;" />

				<h:button value="Back" outcome="/content/task/list"
					style="background-color:#F5FFFA; width: 100px;" />

			</h:panelGrid>

		</h:form>

	</ui:define>
</ui:composition>